package priv.pront.code.robot.roboCom_na_2021;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-08-11 10:54
 */
public class 盲盒包装流水线 {

    static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    static int n, s, k;
    static Map<String, String> map = new HashMap<>();
    static String[] num;

    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        String[] ss = bf.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        s = Integer.parseInt(ss[1]);
        num = bf.readLine().split(" ");
        int count = 0;
        for (int i = 0; i < n / s; i++) {
            int idx = s - 1;
            String[] s1 = bf.readLine().split(" ");
            for (int j = 0; j < s; j++) {
                map.put(num[count++], s1[idx--]);
            }
        }


        k = Integer.parseInt(bf.readLine());
        while (k-- > 0) {
            String query = bf.readLine();
            out.println(map.getOrDefault(query, "Wrong Number"));
        }
        out.close();
    }
}
